<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="./font/iconfont.css">
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 20px;
            background-color: rgb(24, 114, 170);
            color: white;
        }

        header .icon-yonghu {
            margin-right: 10px;
        }

        .container {
            display: flex;
        }

        .container aside {
            width: 120px;
            background-color: rgb(24, 114, 170);
            color: #eee;
            text-align: center;
            line-height: 40px;
        }
        .container aside div{
            margin-top: 10px;
        }
        .container aside div.active {
            background-color: rgb(30, 94, 143);
            color: white;
        }

        .container main {
            flex: 1;
            padding: 20px;
        }

        .container main .inputbox {
            margin: 20px 0;
        }

        .container main .inputbox input {
            height: 40px;
            border-radius: 5px;
            width: 300px;
            padding-left: 20px;
            outline: none;
            border: 1px solid #ccc;
        }

        .container main .inputbox button {
            background-color: rgb(44, 156, 44);
            border-radius: 5px;
            text-align: center;
            line-height: 40px;
            color: white;
            margin-left: 20px;
            padding: 0 30px;
            border: none;
        }

        .container main .add {
            background-color: rgb(44, 156, 44);
            border-radius: 5px;
            text-align: center;
            line-height: 40px;
            color: white;
            padding: 0 30px;
            border: none;
        }

        .container main table {
            margin: 20px 0;
            width: 70%;
            line-height: 40px;
            text-align: center;
        }

        .container main table tr th {
            max-width: 200px;
        }

        .container main table tr th:first-child,
        .container main table tr td:first-child {
            text-align: left;
        }

        .container main .foot {
            width: 70%;
            text-align: center;
            line-height: 40px;

        }

        .container main .foot span {
            border: 1px solid #ccc;
            padding: 0 30px;
            display: inline-block;
        }
        .icon-bianji,.icon-shanchu{
            font-size: 24px;
        }
    </style>
</head>

<body>
    <header>
        <span class="logo">9466云专题</span>
        <div><span class="iconfont icon-yonghu"></span>龙猫(9466云专题)</div>
    </header>
    <section class="container">
        <aside>
            <div><span class="iconfont icon-home"></span> 首页</div>
            <div><span class="iconfont icon-zhuantiguanli"></span> 专题</div>
            <div class="active"><span class="iconfont icon-yonhu"></span> 用户</div>
            <div><span class="iconfont icon-shezhi"></span> 设置</div>
            <div><span class="iconfont icon-xitongrizhi"></span> 日志</div>
        </aside>
        <main>
            <div class="inputbox">
                <input type="text" placeholder="搜索用户"> <button>搜索</button>
            </div>
            <button class="add"><span class="iconfont icon-tianjia"></span> 添加用户</button>
            <table>
                <thead>
                    <tr>
                        <th>邮箱(用户)</th>
                        <th>姓名</th>
                        <th>电话</th>
                        <th>所属组</th>
                        <th>管理员</th>
                        <th>状态</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                    
                </tbody>
            </table>
            <div class="foot">
                <span>上一页</span>
                <span>下一页</span>
            </div>
        </main>
    </section>
</body>

</html>
<script src="./Promise重新封装ajax函数.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/Mock.js/1.0.0/mock.js"></script>
<script src="./text2 mockdata.js"></script>
<script>

    // 任务列表:
    // 1.分页
    // 2.添加用户
    // 3.按关键词搜索用户
    // 4.删除用户
    // 5.编辑
    // 6.登陆(其他页面)
    // 7.注册(其他页面)

    //表格中渲染的数据来自于服务器（ 服务器是提供服务/数据的一方 ）
    //只要向服务器发起ajax请求，就可以获取到来自服务器的数据

    //请求json数据，渲染数据到页面中
    
    //渲染表格数据
    function render(shuju){
        let str = shuju.map((item , index)=>{
            return `
            <tr>
                <td>${item.email}</td>
                <td>${item.name}</td>
                <td>${item.phone}</td>
                <td>${item.ingroup}</td>
                <td>${item.isadmin ? '是' : '否'}</td>
                <td> <span class="statusok">${item.status ? '正常' : '异常'}</span> </td>
                <td> <span class="iconfont icon-bianji"></span> <span class="iconfont icon-shanchu"></span> </td>
            </tr>
            `
        }).join('')
        document.querySelector('tbody').innerHTML = str
    }
    render( shuju.list )
    // let shanchus = [...document.querySelectorAll('.icon-shanchu')]
    // // console.log(shanchus);
    // shanchus.forEach((item , index)=>{
    //     // console.log(item);
    //     item.onclick = function(e){
    //         console.log(111);
    //         shuju.list.splice(index , 1)
    //         // console.log(shuju.list);
    //         render(shuju.list)
    //     }
    // })
</script>